package com.lovo.sgproj.service.imp;

import com.lovo.sgproj.bean.StudentBean;
import com.lovo.sgproj.dao.StudentDAO;
import com.lovo.sgproj.dao.imp.StudentDAOImp;
import com.lovo.sgproj.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
@Component
public class StudentServiceImp implements StudentService {
    @Autowired
    StudentDAO stuDAO;

    @Override
    public ArrayList<StudentBean> showAllStudent() {
        return stuDAO.findAllStudent();
    }

    @Override
    public void studentInRoom(StudentBean student) {
        stuDAO.insertStudent(student);
    }

    @Override
    public void studentOutRoom(int stuId) {
        stuDAO.deleteStudent(stuId);
    }

    @Override
    public StudentBean showStudent(int stuId) {
        return stuDAO.getStudentByID(stuId);
    }

    @Override
    public void changeStudentRoom(int stuId, int roomId) {
        stuDAO.updateStudentRoom(stuId, roomId);
    }

    @Override
    public ArrayList<StudentBean> showStudentsByCondition(String stuName, String className, String roomAddress) {
        return stuDAO.findStudentByCondition(stuName, className, roomAddress);
    }
}
